package com.joker.aigc.oj.service.impl.codesandbox;



import com.joker.aigc.oj.domain.dto.code.ExecuteCodeRequest;
import com.joker.aigc.oj.domain.dto.code.ExecuteCodeResponse;
import com.joker.aigc.oj.service.CodeSandbox;
import com.joker.aigc.oj.service.impl.template.cpp.CppNativeAcmSandbox;
import com.joker.aigc.oj.service.impl.template.java.JavaNativeAcmSandbox;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * 判题的真实路径
 */
@Service
@Slf4j
public class NativeCodeSandbox implements CodeSandbox {


    @Resource
    private JavaNativeAcmSandbox javaNativeAcmSandbox;

    @Resource
    private CppNativeAcmSandbox cppNativeAcmSandbox;

    @Override
    public ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest) {
        System.out.println("NativeCodeSandbox 执行了");
        List<String> inputList = executeCodeRequest.getInputList();
        String code = executeCodeRequest.getCode();
        String language = executeCodeRequest.getLanguage();

        switch (language) {
            case "java":
                return javaNativeAcmSandbox.executeJavaCode(inputList, code);
            case "cpp":
                return cppNativeAcmSandbox.executeCppCode(inputList, code);
            default:
                return null;
        }

    }
}
